//首页的文字飘起来


var pageW = document.documentElement.clientWidth;
var pageH = document.documentElement.clientHeight;
function rand_w(div_w){
	return Math.ceil(Math.random()*(pageW-div_w));
}
function rand_h(div_h){
	return Math.ceil(Math.random()*(pageH-div_h));
}
function rgb_r(){
	return Math.ceil(Math.random()*255);
}
function rgb_g(){
	return Math.ceil(Math.random()*255);
}
function rgb_b(){
	return Math.ceil(Math.random()*255);
}

var div_a=document.getElementById("all");
var all_id=[];
for (var i=0;i<div_a.childElementCount;i++){
	all_id.push(div_a.children[i].id);
}

function move(div_id){
	var box = document.getElementById(div_id);
	var x =1;//偏移量
	var y=1;
	var bleft=parseInt(rand_w(box.clientWidth));
	var btop=parseInt(rand_h(box.clientHeight));
	
	var t= setInterval(
		function(){
			var ft="64px";
			box.style.fontSize=ft;
			bleft = parseInt(rand_w(box.clientWidth))+"px";
			btop  = parseInt(rand_h(box.clientHeight))+"px";
			box.style.left = bleft;
			box.style.top = btop;
		},10);
	box.onmouseover= function (){
		clearInterval(t);
	}
	box.onmouseout=function(){
		t= setInterval(
			function(){
				if(parseInt(bleft)>=(pageW-box.clientWidth) || parseInt(bleft)<0){
					x=-x;//变向
				}
				if(parseInt(btop)>=(pageH-box.clientHeight) || parseInt(btop)<0){
					y=-y;
				}
				bleft = parseInt(bleft)+x+"px";
				btop  = parseInt(btop)+y+"px";
				box.style.left = bleft;
				box.style.top = btop;
				box.childNodes[1].style.color="rgb("+rgb_r()+","+rgb_g()+","+rgb_b()+")";
			},10);
	}
}
//move(div_id);
//move("box2");
for(key in all_id){
	move(all_id[key]);
}
